<?php

namespace App\Models\Library;

use Illuminate\Database\Eloquent\Model;
use Laravel\Scout\Searchable;

// 准用染发剂
class ApprovedTint extends Model
{
//    use Searchable;

    protected $table = "library_approved_tints";
    protected $primaryKey = "id";

    protected $fillable = [
        'name_zh',
        'name_en',
        'zhg_sn',
        'is_updated',
        'zhg_detail_path',
        'ox_max',
        'nox_max',
        'other_limits',
        'note',
        'status'
    ];

    /**
     * 指定 搜索索引中存储的唯一ID
     * @return mixed
     */
    public function getScoutKey()
    {
        return $this->id;
    }

    /**
     * 指定 搜索索引中存储的唯一ID的键名
     * @return string
     */
    public function getScoutKeyName()
    {
        return 'id';
    }

    /**
     * Get the name of the index associated with the model.
     *
     * @return string
     */
    public function searchableAs()
    {
        return $this->table;
    }

    public function toSearchableArray()
    {
        return [
            'id' => $this->id,
            'name_zh' => $this->name_zh,
            'name_en' => $this->name_en,
            'ox_max' => $this->ox_max,
            'nox_max' => $this->nox_max,
            'other_limits' => $this->other_limits,
            'note' => $this->note,
            'status' => $this->status,
            'created_at' => $this->created_at,
        ];
    }
}
